//
//  ViewController.m
//  SqliteManagerDemo
//
//  Created by US bike on 2017/9/4.
//  Copyright © 2017年 US bike. All rights reserved.
//

#import "ViewController.h"
#import "KiwipenRecord.h"
#import "SqliteManager.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *deleteRecordItemTextField;
@property (weak, nonatomic) IBOutlet UITextField *deleteVideoItemTextField;
@property (weak, nonatomic) IBOutlet UITextField *pageIndexTextField;
@property (weak, nonatomic) IBOutlet UITextField *queryRecordItemTextField;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    
    
}


- (IBAction)addRecordItem:(id)sender {
    [[SqliteManager shareManager] addRecordItemWithRecord:[KiwipenRecord createTestRecord]];
    
    
}

- (IBAction)deleteRecordItem:(id)sender {
    
    if (self.deleteRecordItemTextField.hasText) {
        [[SqliteManager shareManager] deleteRecordItemWithRecordID:self.deleteRecordItemTextField.text];

    } else {
        NSLog(@"请新输入recordId");
    }
    
}

- (IBAction)deleteVideoItem:(id)sender {
    if (self.deleteVideoItemTextField.hasText) {
        [[SqliteManager shareManager] deleteVideoRecordItemWithRecordID:self.deleteVideoItemTextField.text];
        
    } else {
        NSLog(@"请新输入recordId");
    }
    
}

- (IBAction)queryAllDatas:(id)sender {
    
    if (self.pageIndexTextField.hasText) {
        [[SqliteManager shareManager] queryRecordDatasWithPageIndex:[self.pageIndexTextField.text integerValue]];
        
    } else {
        NSLog(@"请输入pageIndex");
    }
    

}
- (IBAction)queryRecordItem:(id)sender {
    
    if (self.queryRecordItemTextField.hasText) {
        [[SqliteManager shareManager] queryRecordDataWithRecordID:self.queryRecordItemTextField.text];
    } else {
        NSLog(@"请输入recordID");
    }
}

- (void) touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:YES];
}

@end
